Python/Python Mcq Set 15 Sample Test,Sample questions

Question:
 To include the use of functions which are present in the random library, we must use the option:

1. import random

2.random.h

3. import.random

4. random.random

Posted Date:-2022-01-02 08:15:44


Question:
 What is returned by math.modf(1.0)?

1.(0.0, 1.0)

2. (1.0, 0.0)

3.(0.5, 1)

4. (0.5, 1.0)

Posted Date:-2022-01-02 07:59:09


Question:
 What is the interval of the value generated by the function random.random(), assuming that the random module has already been imported?

1.(0,1)

2. (0,1]

3.[0,1]

4. [0,1)

Posted Date:-2022-01-02 08:36:24


Question:
 What will be the output of the following Python code?

import datetime
d=datetime.date(2017,06,18)
print(d)

1. Error

2. 2017-06-18

3. 18-06-2017

4.06-18-2017

Posted Date:-2022-01-02 08:06:13


Question:
 What will be the output of the following Python code?

random.randrange(0,91,5)

1. 10

2.18

3.79

4.95

Posted Date:-2022-01-02 08:36:46


Question:
 What will be the output of the following Python code?
import random
random.choice(2,3,4)

1.An integer other than 2, 3 and 4

2.Either 2, 3 or 4

3. Error

4.3 only

Posted Date:-2022-01-02 08:19:44


Question:
 Which of the following functions can be used to find the coordinated universal time, assuming that the datetime module has already been imported?

1.datetime.utc()

2.datetime.datetime.utc()

3.datetime.utcnow()

4.datetime.datetime.utcnow()

Posted Date:-2022-01-02 08:10:41


Question:
Both the functions randint and uniform accept ____________ parameters.

1.0

2.1

3.3

4.2

Posted Date:-2022-01-02 08:37:08


Question:
Point out the error (if any) in the code shown below if the system date is 18th June, 2017?

tday=datetime.date.today()
bday=datetime.date(2017,9,18)
till_bday=bday-tday
print(till_bday)

1. 3 months, 0:00:00

2. 90 days, 0:00:00

3. 3 months 2 days, 0:00:00

4.92 days, 0:00:00

Posted Date:-2022-01-02 08:08:45


Question:
The sleep function (under the time module) is used to ____

1. Pause the code for the specified number of seconds

2. Return the specified number of seconds, in terms of milliseconds

3.Stop the execution of the code

4.Return the output of the code had it been executed earlier by the specified number of seconds

Posted Date:-2022-01-02 08:13:09


Question:
The value returned when we use the function isoweekday() is ______ and that for the function weekday() is ________ if the system date is 19th June, 2017 (Monday).

1.0,0

2.0,1

3. 1,0

4.1,1

Posted Date:-2022-01-02 08:09:12


Question:
What does math.sqrt(X, Y) do?

1.calculate the Xth root of Y

2. calculate the Yth root of X

3.error

4.return a tuple with the square root of X and Y

Posted Date:-2022-01-02 08:05:04


Question:
What does the function math.frexp(x) return?

1.a tuple containing the mantissa and the exponent of x

2. a list containing the mantissa and the exponent of x

3.a tuple containing the mantissa of x

4.a list containing the exponent of x

Posted Date:-2022-01-02 07:55:14


Question:
What is returned by int(math.pow(3, 2))?

1. 6

2.9

3. error, third argument required

4.error, too many arguments

Posted Date:-2022-01-02 08:04:02


Question:
What is returned by math.expm1(p)?

1. (math.e ** p) – 1

2.math.e ** (p – 1)

3. error

4.none of the mentioned

Posted Date:-2022-01-02 08:02:50


Question:
What is returned by math.isfinite(float(‘inf’))?

1.True

2.False

3.None

4.error

Posted Date:-2022-01-02 07:56:32


Question:
What is returned by math.isfinite(float(‘nan’))?

1. True

2. False

3.None

4.error

Posted Date:-2022-01-02 07:56:56


Question:
What is the default base used when math.log(x) is found?

1.e

2.10

3.2

4.none of the mentioned

Posted Date:-2022-01-02 08:03:12


Question:
What is the output of print(math.trunc(‘3.1’))?

1. 3

2.3.0

3. error

4.none of the mentioned

Posted Date:-2022-01-02 08:01:53


Question:
What is the result of math.fsum([.1 for i in range(20)])?

1. 2.0

2. 20

3.2

4.2.0000000000000004

Posted Date:-2022-01-02 07:55:35


Question:
What is the result of math.trunc(3.1)?

1. 3.0

2. 3

3.0.1

4.1

Posted Date:-2022-01-02 08:01:33


Question:
What is the result of sum([.1 for i in range(20)])?

1. 2.0

2.20

3.2

4.2.0000000000000004

Posted Date:-2022-01-02 07:56:11


Question:
What is the value of x if x = math.ldexp(0.5, 1)?

1.1

2.2.0

3.0.5

4.none of the mentioned

Posted Date:-2022-01-02 07:58:43


Question:
What is the value of x if x = math.sqrt(4)?

1. 2

2.2.0

3.(2, -2)

4. (2.0, -2.0)

Posted Date:-2022-01-02 08:04:37


Question:
What is x if x = math.isfinite(float(‘0.0’))?

1. True

2.False

3.None

4. error

Posted Date:-2022-01-02 07:57:23


Question:
What will be the output if we try to extract only the year from the following Python code? (time.struct_time(tm_year=2017, tm_mon=6, tm_mday=25, tm_hour=18, tm_min=26, tm_sec=6, tm_wday=6, tm_yday=176, tm_isdst=0))

import time
t=time.localtime()
print(t)

1. t[1]

2.tm_year

3. t[0]

4.t_year

Posted Date:-2022-01-02 08:14:31


Question:
What will be the output of the following Python code if the system date is 18th August, 2016?

tday=datetime.date.today()
print(tday.month())

1.August

2. Aug

3. 08

4.8

Posted Date:-2022-01-02 08:06:36


Question:
What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

import datetime
tday=datetime.date.today()
print(tday)

1.18-06-2017

2.06-18-2017

3.2017-06-18

4.error

Posted Date:-2022-01-02 08:07:06


Question:
What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

tday=datetime.date.today()
print(tday.weekday())

1.6

2.1

3.0

4.7

Posted Date:-2022-01-02 08:07:26


Question:
What will be the output of the following Python code if the system date is 21st June, 2017 (Wednesday)?

tday=datetime.date.today()
print(tday.isoweekday())

1.Wed

2.Wednesday

3. 2

4.3

Posted Date:-2022-01-02 08:07:53


Question:
What will be the output of the following Python code if the system date is: 6/19/2017

tday=datetime.date.today()
tdelta=datetime.timedelta(days=10)
print(tday+tdelta)

1.2017-16-19

2.2017-06-9

3.2017-06-29

4. error

Posted Date:-2022-01-02 08:09:58


Question:
What will be the output of the following Python code?

>>> -float('inf') + float('inf')

1. inf

2.nan

3. 0

4.0.01 to 20%

Posted Date:-2022-01-02 07:57:47


Question:
What will be the output of the following Python code?

import datetime
d=datetime.date(2016,7,24)
print(d)

1.Error

2.2017-07-24

3.2017-7-24

4. 24-7-2017

Posted Date:-2022-01-02 08:05:48


Question:
What will be the output of the following Python code?

import random
random.choice([10.4, 56.99, 76])

1.Error

2.Either 10.4, 56.99 or 76

3. Any number other than 10.4, 56.99 and 76

4. 56.99 only

Posted Date:-2022-01-02 08:20:09


Question:
What will be the output of the following Python code?

import time
for i in range(0,5):
	print(i)
	time.sleep(2)

1.After an interval of 2 seconds, the numbers 1, 2, 3, 4, 5 are printed all together

2.After an interval of 2 seconds, the numbers 0, 1, 2, 3, 4 are printed all together

3. Prints the numbers 1, 2, 3, 4, 5 at an interval of 2 seconds between each number

4. Prints the numbers 0, 1, 2, 3, 4 at an interval of 2 seconds between each number

Posted Date:-2022-01-02 08:13:55


Question:
What will be the output of the following Python code?

import time
t=(2010, 9, 20, 8, 15, 12, 6)
time.asctime(t)

1. ‘20 Sep 2010 8:15:12 Sun’

2. ‘2010 20 Sept 08:15:12 Sun’

3. ‘Sun Sept 20 8:15:12 2010’

4. error

Posted Date:-2022-01-02 08:12:06


Question:
What will be the output of the following Python code?

import time
t=(2010, 9, 20, 8, 45, 12, 6, 0, 0)
time.asctime(t)

1. ‘Sep 20 2010 08:45:12 Sun’

2.‘Sun Sep 20 08:45:12 2010’

3.’20 Sep 08:45:12 Sun 2010’

4. ‘2010 20 Sep 08:45:12 Sun’

Posted Date:-2022-01-02 08:12:38


Question:
What will be the output of the following Python code?

import time
time.asctime()

1. Current date only

2.UTC time

3.Current date and time

4.Current time only

Posted Date:-2022-01-02 08:11:39


Question:
What will be the output of the following Python code?

random.randrange(1,100,10)

1.32

2.67

3.91

4.80

Posted Date:-2022-01-02 08:38:20


Question:
What will be the output of the following Python code?

random.seed(3)
random.randint(1,5)
2
random.seed(3)
random.randint(1,5)

1.3

2.2

3. Any integer between 1 and 5, including 1 and 5

4.Any integer between 1 and 5, excluding 1 and 5

Posted Date:-2022-01-02 08:35:59


Question:
What will be the output of the following Python code?
import time
time.time()

1.The number of hours passed since 1st January, 1970

2.The number of days passed since 1st January, 1970

3. The number of seconds passed since 1st January, 1970

4.The number of minutes passed since 1st January, 1970

Posted Date:-2022-01-02 08:11:16


Question:
What will be the output of the following Python code?
print(math.isinf(float('-inf')))

1. error, the minus sign shouldn’t have been inside the brackets

2.error, there is no function called isinf

3.True

4.False

Posted Date:-2022-01-02 07:58:18


Question:
What will be the output of the following Python function (random module has already been imported)?

random.choice('sun')

1. sun

2. u

3.either s, u or n

4.error

Posted Date:-2022-01-02 08:20:35


Question:
What will be the output of the following Python function if the random module has already been imported?

random.randint(3.5,7)

1. Error

2.Any integer between 3.5 and 7, including 7

3. Any integer between 3.5 and 7, excluding 7

4. The integer closest to the mean of 3.5 and 7

Posted Date:-2022-01-02 08:32:50


Question:
What will be the output of the following Python function, assuming that the random library has already been included?

random.shuffle[1,2,24]

1.Randomized list containing the same numbers in any order

2.The same list, that is [1,2,24]

3.A list containing any random numbers between 1 and 24

4. Error

Posted Date:-2022-01-02 08:42:15


Question:
What will be the output of the following Python function, assuming that the random module has already been imported?

random.uniform(3,4)

1.Error

2. Either 3 or 4

3. Any integer other than 3 and 4

4.Any decimal value between 3 and 4

Posted Date:-2022-01-02 08:29:50


Question:
Which of the following aren’t defined in the math module?

1. log2()

2. log10()

3.logx()

4.none of the mentioned

Posted Date:-2022-01-02 08:03:40


Question:
Which of the following functions helps us to randomize the items of a list?

1.seed

2. randomise

3.shuffle

4.uniform

Posted Date:-2022-01-02 08:35:24


Question:
Which of the following is the same as math.exp(p)?

1. e ** p

2. math.e ** p

3.p ** e

4.p ** math.e

Posted Date:-2022-01-02 08:02:21


Question:
Which of the following will throw an error if used after the following Python code?

tday=datetime.date.today()
bday=datetime.date(2017,9,18)
t_day=bday-tday

1.print(t_day.seconds)

2.print(t_day.months)

3. print(t_day.max)

4.print(t_day.resolution)

Posted Date:-2022-01-02 08:09:35


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!